package com.api.shopapi.service.impl;

import com.api.shopapi.entity.Serve;
import com.api.shopapi.mapper.ServeMapper;
import com.api.shopapi.service.ServeService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("ServeServiceImplOne")
public class ServeServiceImpl implements ServeService {

    @Autowired
    private ServeMapper serveMapper;

    @Override
    public int insert(Serve serve){
        return serveMapper.insert(serve);
    }

    @Override
    public int deleteByServeCode(String serveCode){
        return serveMapper.deleteByServeCode(serveCode);
    }

    @Override
    public int updateByServeCode(Serve serve){
        return serveMapper.updateByServeCode(serve);
    }

    @Override
    public Serve getByServeCode(String serveCode){
        return serveMapper.getByServeCode(serveCode);
    }

    @Override
    public Serve getByUserCode(String userCode){
        return serveMapper.getByUserCode(userCode);
    }

    @Override
    public List<Serve> getList(){
        return serveMapper.getList();
    }


    @Override
    public int update(Serve serve) {
        return serveMapper.update(serve);
    }

    @Override
    public PageInfo<Serve> getPageList(int pageIndex, int pageSize, String name, int serviceStatus,String businessCode) {
        PageHelper.startPage(pageIndex,pageSize);
        List<Serve> serveList =serveMapper.getPageList(name,serviceStatus,businessCode);
        return new PageInfo<>(serveList);
    }

    @Override
    public List<Serve> getListByBusinessCode(@Param("businessCode") String businessCode){
        return serveMapper.getListByBusinessCode(businessCode);
    }

    //获取社区绑定的所有服务人员
    @Override
    public List<Serve> getListByZoneCode(String zoneCode){
        return serveMapper.getListByZoneCode(zoneCode);
    }

}
